<?php

use yii\helpers\Html;
use yii\grid\GridView;

/* @var $this yii\web\View */
/* @var $searchModel backend\models\SearchAgentModel */
/* @var $dataProvider yii\data\ActiveDataProvider */
?>
<div class="agent-model-index">


    <?php echo $this->render('_search', ['model' => $searchModel]); ?>

    <p>
        <?php if (\backend\components\MenuHelper::checkRoute('create')) {
            echo Html::a('添加代理商', ['create'], ['class' => 'btn btn-success']);
        } ?>
    </p>
    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'columns' => [
            ['label' => '二维码', 'format' => 'raw', "headerOptions" => ["width" => "140"], 'value' => function ($model) {
                return Html::a("<img src='https://api.qrserver.com/v1/create-qr-code/?size=100x100&data=http://pocket.all-star.top/house?pid={$model->id}'>",
                    "https://api.qrserver.com/v1/create-qr-code/?size=100x100&data=http://pocket.all-star.top/house?pid={$model->id}", ['target' => '_blank']);
            }],
            'agent_name',
            'phone',
            'workplace',

            [
                'class' => 'yii\grid\ActionColumn',
                'template' => \backend\components\MenuHelper::filterActionColumn('{update} {delete}')
            ],
        ],
    ]); ?>
</div>
